<template>
  <div id="app">
    <h2>我是根组件，数据：{{ name }}---{{ price }}</h2>
    <h2>总和：{{ sum }}</h2>
    <button @click="sum++">sum++</button>
  </div>
</template>

<script>
import { ref, reactive, toRefs,readonly, isRef,isReactive,isReadonly,isProxy } from "vue";
export default {
  name: "App",
  setup(props) {

    const car = reactive({name: "奔驰",price: "40W"});
    const sum = ref(0)
    const car2 = readonly(car)

    //判断API
    // console.log(isReactive(sum));//false
    // console.log(isReadonly(sum));//false
    console.log(isProxy(sum));//false
    // console.log(isRef(sum));  //true
    // console.log(isReactive(car));   //true
    // console.log(isReactive(car2));  //true
    // console.log(isReadonly(car));  //false
    // console.log(isReadonly(car2));  //true
    console.log(isProxy(car));  //true
    console.log(isProxy(car2)); //true

    return {
      ...toRefs(car),
      sum
    };
  },
};
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding: 10px;
  background: orange;
}
</style>
